﻿<UserControl x:Class="MissedMemo.MeatAndCheeseDisc.OrderEntry.viewCustomerDetails"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:MissedMemo.MeatAndCheeseDisc.OrderEntry"
    Height="540" Width="400">

    <UserControl.Resources>
        <ResourceDictionary>

            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="resColorScheme.xaml" />
            </ResourceDictionary.MergedDictionaries>

            
            <Style TargetType="{x:Type TextBlock}">
                <Setter Property="HorizontalAlignment" Value="Right" />
                <Setter Property="VerticalAlignment" Value="Center" />
                <Setter Property="TextAlignment" Value="Center" />
            </Style>

            
            <Style TargetType="{x:Type TextBox}">
                <Setter Property="Margin" Value="5,0" />
                <Setter Property="VerticalAlignment" Value="Center" />
                <Setter Property="Validation.ErrorTemplate">
                    <Setter.Value>
                        <ControlTemplate>
                            <DockPanel>
                                <Image DockPanel.Dock="Right" Height="20" Source="Resources\UserInputError.ico"
                                           ToolTip="{Binding ElementName=item, Path=AdornedElement.(Validation.Errors)[0].ErrorContent}"/>
                                <Border BorderBrush="Red" BorderThickness="2">
                                    <AdornedElementPlaceholder Name="item" />
                                </Border>
                            </DockPanel>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
                <Style.Triggers>
                    <Trigger Property="Validation.HasError" Value="True" >
                        <Setter Property="ToolTip"
                            Value="{Binding RelativeSource={RelativeSource Self},
                            Path=(Validation.Errors)[0].ErrorContent}" />
                    </Trigger>
                </Style.Triggers>
            </Style>

            
            <Style TargetType="{x:Type RowDefinition}" >
                <Setter Property="Height" Value="36" />
            </Style>

        </ResourceDictionary>
    </UserControl.Resources>
    
    
    <Grid Margin="20" >

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="auto" />
            <ColumnDefinition Width="35*" />
            <ColumnDefinition Width="15*" />
            <ColumnDefinition Width="35*" />
        </Grid.ColumnDefinitions>

        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
            <RowDefinition Height="0.5*"/>
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
            <RowDefinition Height="0.5*"/>
            <RowDefinition Height="5*"/>
        </Grid.RowDefinitions>

        <TextBlock Text="Name:" Grid.Column="0" Grid.Row="0" />
        <TextBox Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="0" Text="{Binding Path=Customer.Name}" />
        
        <TextBlock Text="E-mail:" Grid.Column="0" Grid.Row="1" />
        <TextBox Grid.Column="1" Grid.Row="1" >
            <TextBox.Text>
                <Binding Path="Customer.EMail" NotifyOnValidationError="True" >
                    <Binding.ValidationRules>
                        <local:validateRegExpression FormatId="EMail" />
                    </Binding.ValidationRules>
                </Binding>
            </TextBox.Text>
        </TextBox>
        
        <TextBlock Text="Phone:" Grid.Column="0" Grid.Row="2" />
        <TextBox Grid.Column="1" Grid.Row="2" >
           <TextBox.Text>
                <Binding Path="Customer.Phone" NotifyOnValidationError="True" >
                    <Binding.ValidationRules>
                        <local:validateRegExpression FormatId="PhoneNumber" />
                    </Binding.ValidationRules>
                </Binding>
            </TextBox.Text> 
        </TextBox>
        
        <TextBlock Text="Fax:" Grid.Column="2" Grid.Row="2" />
        <TextBox Grid.Column="3" Grid.Row="2">
           <TextBox.Text>
                <Binding Path="Customer.Fax" NotifyOnValidationError="True" >
                    <Binding.ValidationRules>
                        <local:validateRegExpression FormatId="PhoneNumber" />
                    </Binding.ValidationRules>
                </Binding>
            </TextBox.Text> 
        </TextBox>
        
        <TextBlock Text="Addr1:" Grid.Column="0" Grid.Row="4" />
        <TextBox Grid.Column="1" Grid.ColumnSpan="3" Grid.Row="4" Text="{Binding Path=Customer.Address.Addr1}" />
        
        <TextBlock Text="Addr2:" Grid.Column="0" Grid.Row="5" />
        <TextBox Grid.Column="1" Grid.ColumnSpan="3" Grid.Row="5" Text="{Binding Path=Customer.Address.Addr2}" />
        
        <TextBlock Text="City:" Grid.Column="0" Grid.Row="6" />
        <TextBox Grid.Column="1" Grid.Row="6"  Text="{Binding Path=Customer.Address.City}" />
        
        <TextBlock Text="State:" Grid.Column="0" Grid.Row="7" />
        <TextBox Grid.Column="1" Grid.Row="7"  Text="{Binding Path=Customer.Address.State}" />
        
        <TextBlock Text="Zip:" Grid.Column="2" Grid.Row="7" />
        <TextBox Grid.Column="3" Grid.Row="7"  >
            <TextBox.Text>
                <Binding Path="Customer.Address.Zip" NotifyOnValidationError="True" >
                    <Binding.ValidationRules>
                        <local:validateRegExpression FormatId="ZipCode" />
                    </Binding.ValidationRules>
                </Binding>
            </TextBox.Text>
        </TextBox>
        
        
        <Grid Grid.Column="0" Grid.Row="9" Grid.ColumnSpan="4" >
            
            <GroupBox Header="Comments" Padding="6" >
    		    <TextBox Style="{x:Null}" TextWrapping="Wrap"
                         Text="{Binding Path=Customer.Comments}" />
    	    </GroupBox>
            
        </Grid>

    </Grid>
    
</UserControl>
